> print("Step 0: Empty Models for Continu-ish Symptoms and Mood")
[1] "Step 0: Empty Models for Continu-ish Symptoms and Mood"
> EmptyY = lmer(data = Example5a, REML = FALSE, formula = symptoms ~ 
+ 1 + (1 | PersonID))
> summary(EmptyY)
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: symptoms ~ 1 + (1 | PersonID)
   Data: Example5a

     AIC      BIC   logLik deviance df.resid 
  1449.0   1461.7   -721.5   1443.0      506 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-2.80554 -0.38564 -0.15477  0.42657  3.90626 

Random effects:
 Groups   Name        Variance Std.Dev.
 PersonID (Intercept) 1.18930  1.09055 
 Residual             0.61618  0.78497 
Number of obs: 509, groups:  PersonID, 105

Fixed effects:
             Estimate Std. Error        df t value  Pr(>|t|)
(Intercept)   1.29395    0.11204 102.98114  11.549 < 2.2e-16
> icc(EmptyY)
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.659
  Unadjusted ICC: 0.659
> EmptyM = lmer(data = Example5a, REML = FALSE, formula = mood2 ~ 
+ 1 + (1 | PersonID))
> summary(EmptyM)
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: mood2 ~ 1 + (1 | PersonID)
   Data: Example5a

     AIC      BIC   logLik deviance df.resid 
   379.7    392.4   -186.9    373.7      506 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.91735 -0.39081 -0.17558  0.09302  4.45794 

Random effects:
 Groups   Name        Variance Std.Dev.
 PersonID (Intercept) 0.052399 0.22891 
 Residual             0.093047 0.30504 
Number of obs: 509, groups:  PersonID, 105

Fixed effects:
              Estimate Std. Error         df t value  Pr(>|t|)
(Intercept)  -0.795641   0.026143 102.794948 -30.434 < 2.2e-16
> icc(EmptyM)
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.360
  Unadjusted ICC: 0.360
> print("Step 0: Empty Model for Binary Stressors")
[1] "Step 0: Empty Model for Binary Stressors"
> print("Using logit link and 15 quadrature points to match Mplus")
[1] "Using logit link and 15 quadrature points to match Mplus"
> EmptyX = glmer(data = Example5a, family = binomial(link = "logit"), 
+ nAGQ = 15, formula = stressor ~ 1 + (1 | PersonID))
> summary(EmptyX)
Generalized linear mixed model fit by maximum likelihood (Adaptive Gauss-Hermite Quadrature, nAGQ = 15) ['glmerMod']
 Family: binomial  ( logit )
Formula: stressor ~ 1 + (1 | PersonID)
   Data: Example5a

     AIC      BIC   logLik deviance df.resid 
   636.2    644.7   -316.1    632.2      507 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.57229 -0.59067 -0.37851  0.63601  1.69298 

Random effects:
 Groups   Name        Variance Std.Dev.
 PersonID (Intercept) 2.6701   1.6341  
Number of obs: 509, groups:  PersonID, 105

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.26992    0.19656 -1.3732   0.1697
> icc(EmptyX)
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.448
  Unadjusted ICC: 0.448

   

> print("Step 1a: X Stressors Predicting Symptoms Y using Univ MLM")
[1] "Step 1a: X Stressors Predicting Symptoms Y using Univ MLM"
> Step1 = lmer(data = Example5a, REML = FALSE, formula = symptoms ~ 
+ 1 + women + age80 + stressor + PMstress40 + women:age80 + 
+ 
+ (1 | PersonID))
> print("Show results using Satterthwaite DDF")
[1] "Show results using Satterthwaite DDF"
> summary(Step1, ddf = "Satterthwaite")
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: symptoms ~ 1 + women + age80 + stressor + PMstress40 + women:age80 +      (1 | PersonID)
   Data: Example5a

     AIC      BIC   logLik deviance df.resid 
  1424.4   1458.3   -704.2   1408.4      501 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-3.06059 -0.43618 -0.09436  0.34167  3.88257 

Random effects:
 Groups   Name        Variance Std.Dev.
 PersonID (Intercept) 0.83721  0.91499 
 Residual             0.61340  0.78320 
Number of obs: 509, groups:  PersonID, 105

Fixed effects:
              Estimate Std. Error         df t value           Pr(>|t|)
(Intercept)   1.586495   0.193743 115.159895  8.1887 0.0000000000004043
women        -0.518685   0.219907 105.308416 -2.3587           0.020186
age80         0.096764   0.033291 108.203337  2.9066           0.004432
stressor      0.110013   0.094868 403.459632  1.1596           0.246882
PMstress40    1.335160   0.301870 127.465958  4.4230 0.0000206452444044
women:age80  -0.106495   0.037894 107.128853 -2.8103           0.005886

Correlation of Fixed Effects:
            (Intr) women  age80  strssr PMst40
women       -0.841                            
age80        0.168 -0.147                     
stressor    -0.201  0.004 -0.002              
PMstress40  -0.012  0.006 -0.013 -0.316       
women:age80 -0.148  0.110 -0.879  0.000  0.016
> print("BP X to Y Effect")
[1] "BP X to Y Effect"
> contest1D(Step1, ddf = "Satterthwaite", L = c(0, 0, 0, 1, 1, 
+ 0))
   Estimate Std. Error        df   t value        Pr(>|t|)
1 1.4451731 0.28643326 103.60072 5.0454096 0.0000019391296

   

> print("Step 1b: X Stressors Predicting Symptoms Y using Multiv MLM -- No Placeholder Version")
[1] "Step 1b: X Stressors Predicting Symptoms Y using Multiv MLM -- No Placeholder Version"
> Step1bSyntax = "\nlevel: 1\n# L1 R: residual variance in symptoms\n  symptoms ~~ symptoms\n# L1 WP stress -> symptoms\n  symptoms ~ (WPXtoY)*stress\n\nlevel: 2\n# Fixed intercepts for symptoms\n  symptoms ~ 1\n# L2 G: random intercept variance in symptoms\n  symptoms ~~ symptoms\n# BP fixed effects of women*age80 -> symptoms\n  symptoms ~ women + age80 + agesex\n# Contextual fixed effect of stress -> symptoms\n  symptoms ~ (conXtoY)*PMstr40\n# Create BP fixed effect of stress -> symptoms\n  BPXtoY := conXtoY + WPXtoY\n"
> Step1bMSEM = sem(data = Example5a, model = Step1bSyntax, cluster = "PersonID", 
+ estimator = "ML", mimic = "mplus")
> summary(Step1bMSEM, fit.measures = TRUE)
lavaan 0.6-19 ended normally after 28 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         8

  Number of observations                           509
  Number of clusters [PersonID]                    105
  Number of missing patterns -- level 1              1
  Number of missing patterns -- level 2              1

Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Model Test Baseline Model:

  Test statistic                                34.525
  Degrees of freedom                                 5
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000
  Tucker-Lewis Index (TLI)                       1.000
                                                      
  Robust Comparative Fit Index (CFI)                NA
  Robust Tucker-Lewis Index (TLI)                   NA

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)               -704.221
  Loglikelihood unrestricted model (H1)       -704.221
                                                      
  Akaike (AIC)                                1424.441
  Bayesian (BIC)                              1458.301
  Sample-size adjusted Bayesian (SABIC)       1432.908

Root Mean Square Error of Approximation:

  RMSEA                                          0.000
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.000
  P-value H_0: RMSEA <= 0.050                       NA
  P-value H_0: RMSEA >= 0.080                       NA
                                                      
  Robust RMSEA                                      NA
  90 Percent confidence interval - lower            NA
  90 Percent confidence interval - upper            NA
  P-value H_0: Robust RMSEA <= 0.050                NA
  P-value H_0: Robust RMSEA >= 0.080                NA

Standardized Root Mean Square Residual (corr metric):

  SRMR (within covariance matrix)                0.000
  SRMR (between covariance matrix)               0.000

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian


Level 1 [within]:

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  symptoms ~                                          
    stress  (WPXY)    0.110    0.095    1.160    0.246

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          0.613    0.043   14.192    0.000


Level 2 [PersonID]:

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  symptoms ~                                          
    women            -0.519    0.220   -2.359    0.018
    age80             0.097    0.033    2.906    0.004
    agesex           -0.106    0.038   -2.810    0.005
    PMstr40 (cnXY)    1.335    0.302    4.423    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          1.586    0.194    8.188    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          0.837    0.134    6.233    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    BPXtoY            1.445    0.286    5.045    0.000


   

> print("Step 2a-ish: M Mood Predicting Symptoms Y using Univ MLM")
[1] "Step 2a-ish: M Mood Predicting Symptoms Y using Univ MLM"
> Step2 = lmer(data = Example5a, REML = FALSE, formula = symptoms ~ 
+ 1 + women + age80 + mood2 + PMmood2 + women:age80 + (1 | 
+ 
+ PersonID))
> print("Show results using Satterthwaite DDF")
[1] "Show results using Satterthwaite DDF"
> summary(Step2, ddf = "Satterthwaite")
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: symptoms ~ 1 + women + age80 + mood2 + PMmood2 + women:age80 +      (1 | PersonID)
   Data: Example5a

     AIC      BIC   logLik deviance df.resid 
  1421.7   1455.5   -702.8   1405.7      501 

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-3.15343 -0.48004 -0.12575  0.39605  4.05392 

Random effects:
 Groups   Name        Variance Std.Dev.
 PersonID (Intercept) 0.81615  0.90341 
 Residual             0.61273  0.78277 
Number of obs: 509, groups:  PersonID, 105

Fixed effects:
              Estimate Std. Error         df t value  Pr(>|t|)
(Intercept)   3.265483   0.345801 105.879510  9.4432 1.015e-15
women        -0.518135   0.217506 105.334760 -2.3822   0.01900
age80         0.066899   0.033494 107.758448  1.9973   0.04831
mood2         0.159103   0.127716 404.161789  1.2458   0.21358
PMmood2       1.810999   0.390993 132.127348  4.6318 8.572e-06
women:age80  -0.091762   0.037637 107.045874 -2.4381   0.01641

Correlation of Fixed Effects:
            (Intr) women  age80  mood2  PMmod2
women       -0.457                            
age80       -0.063 -0.147                     
mood2       -0.001 -0.008  0.013              
PMmood2      0.794  0.012 -0.177 -0.333       
women:age80 -0.004  0.110 -0.877 -0.013  0.090
> print("BP M to Y Effect")
[1] "BP M to Y Effect"
> contest1D(Step2, ddf = "Satterthwaite", L = c(0, 0, 0, 1, 1, 
+ 0))
   Estimate Std. Error      df   t value         Pr(>|t|)
1 1.9701027 0.36873211 104.877 5.3429107 0.00000053576549

   

> print("Step 2b: M Mood Predicting Symptoms Y using Multiv MLM -- No Placeholder Version")
[1] "Step 2b: M Mood Predicting Symptoms Y using Multiv MLM -- No Placeholder Version"
> Step2bSyntax = "\nlevel: 1\n# L1 R: residual variance in symptoms and mood\n  symptoms ~~ symptoms; mood2 ~~ mood2\n# L1 WP mood -> symptoms\n  symptoms ~ (WPMtoY)*mood2\n\nlevel: 2\n# Fixed intercepts for symptoms and mood\n  symptoms ~ 1; mood2 ~ 1 \n# L2 G: random intercept variance in symptoms and mood\n  symptoms ~~ symptoms; mood2 ~~ mood2\n# BP fixed effects of women*age80 -> symptoms\n  symptoms ~ women + age80 + agesex\n# BP fixed effect of mood -> symptoms\n  symptoms ~ (BPMtoY)*mood2\n# Create contextual fixed effect of mood -> symptoms\n  conMtoY := BPMtoY - WPMtoY\n"
> Step2bMSEM = sem(data = Example5a, model = Step2bSyntax, cluster = "PersonID", 
+ estimator = "ML", mimic = "mplus")
> summary(Step2bMSEM, fit.measures = TRUE)
lavaan 0.6-19 ended normally after 34 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        11

  Number of observations                           509
  Number of clusters [PersonID]                    105
  Number of missing patterns -- level 1              1
  Number of missing patterns -- level 2              1

Model Test User Model:
                                                      
  Test statistic                                 5.051
  Degrees of freedom                                 3
  P-value (Chi-square)                           0.168

Model Test Baseline Model:

  Test statistic                                40.134
  Degrees of freedom                                 8
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.936
  Tucker-Lewis Index (TLI)                       0.830
                                                      
  Robust Comparative Fit Index (CFI)                NA
  Robust Tucker-Lewis Index (TLI)                   NA

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)               -890.793
  Loglikelihood unrestricted model (H1)       -888.267
                                                      
  Akaike (AIC)                                1803.585
  Bayesian (BIC)                              1850.142
  Sample-size adjusted Bayesian (SABIC)       1815.226

Root Mean Square Error of Approximation:

  RMSEA                                          0.037
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.090
  P-value H_0: RMSEA <= 0.050                    0.580
  P-value H_0: RMSEA >= 0.080                    0.103
                                                      
  Robust RMSEA                                      NA
  90 Percent confidence interval - lower            NA
  90 Percent confidence interval - upper            NA
  P-value H_0: Robust RMSEA <= 0.050                NA
  P-value H_0: Robust RMSEA >= 0.080                NA

Standardized Root Mean Square Residual (corr metric):

  SRMR (within covariance matrix)                0.000
  SRMR (between covariance matrix)               0.085

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian


Level 1 [within]:

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  symptoms ~                                          
    mood2   (WPMY)    0.167    0.128    1.303    0.193

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          0.613    0.043   14.185    0.000
    mood2             0.093    0.007   14.157    0.000


Level 2 [PersonID]:

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  symptoms ~                                          
    women            -0.540    0.220   -2.458    0.014
    age80             0.074    0.034    2.181    0.029
    agesex           -0.098    0.038   -2.582    0.010
    mood2   (BPMY)    2.506    0.530    4.727    0.000

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          3.710    0.463    8.020    0.000
    mood2            -0.795    0.026  -30.455    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          0.754    0.140    5.405    0.000
    mood2             0.052    0.010    5.174    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    conMtoY           2.339    0.558    4.196    0.000


   

> print("Step 3a: Full mediation MLM of Stress --> Mood --> Symptoms -- No Placeholder Version")
[1] "Step 3a: Full mediation MLM of Stress --> Mood --> Symptoms -- No Placeholder Version"
> Step3aSyntax = "\nlevel: 1\n# L1 R: residual variance in symptoms and mood\n  symptoms ~~ symptoms; mood2 ~~ mood2\n# L1 WP stress -> mood\n  mood2 ~ (WPXtoM)*stress\n# L1 WP stress -> symptoms\n  symptoms ~ (WPXtoY)*stress\n# L1 WP mood -> symptoms\n  symptoms ~ (WPMtoY)*mood2\n\nlevel: 2\n# Fixed intercepts for symptoms and mood\n  symptoms ~ 1; mood2 ~ 1 \n# L2 G: random intercept variance in symptoms and mood\n  symptoms ~~ symptoms; mood2 ~~ mood2\n# BP fixed effects of women*age80 -> symptoms\n  symptoms ~ women + age80 + agesex\n# BP fixed effects of women*age80 -> mood\n  mood2 ~ women + age80 + agesex \n# Contextual effect of stress -> symptoms\n  mood2 ~ (conXtoM)*PMstr40\n# Contextual effect of stress -> symptoms\n  symptoms ~ (conXtoY)*PMstr40\n# BP fixed effect of mood -> symptoms\n  symptoms ~ (BPMtoY)*mood2\n\n# Create contextual fixed effect of mood -> symptoms\n  conMtoY := BPMtoY - WPMtoY\n# Create BP fixed effects of stress -> mood and symptoms\n  BPXtoM := conXtoM + WPXtoM\n  BPXtoY := conXtoY + WPXtoY\n# Create indirect effects\n  WPind  := WPXtoM*WPMtoY\n  Conind := conXtoM*conMtoY\n  BPind  := BPXtoM*BPMtoY\n"
> Step3aMSEM = sem(data = Example5a, model = Step3aSyntax, cluster = "PersonID", 
+ estimator = "ML", mimic = "mplus")
> summary(Step3aMSEM, fit.measures = TRUE)
lavaan 0.6-19 ended normally after 54 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        18

  Number of observations                           509
  Number of clusters [PersonID]                    105
  Number of missing patterns -- level 1              1
  Number of missing patterns -- level 2              1

Model Test User Model:
                                                      
  Test statistic                                 0.000
  Degrees of freedom                                 0

Model Test Baseline Model:

  Test statistic                                88.164
  Degrees of freedom                                12
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000
  Tucker-Lewis Index (TLI)                       1.000
                                                      
  Robust Comparative Fit Index (CFI)                NA
  Robust Tucker-Lewis Index (TLI)                   NA

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)               -864.251
  Loglikelihood unrestricted model (H1)       -864.251
                                                      
  Akaike (AIC)                                1764.502
  Bayesian (BIC)                              1840.686
  Sample-size adjusted Bayesian (SABIC)       1783.552

Root Mean Square Error of Approximation:

  RMSEA                                          0.000
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.000
  P-value H_0: RMSEA <= 0.050                       NA
  P-value H_0: RMSEA >= 0.080                       NA
                                                      
  Robust RMSEA                                      NA
  90 Percent confidence interval - lower            NA
  90 Percent confidence interval - upper            NA
  P-value H_0: Robust RMSEA <= 0.050                NA
  P-value H_0: Robust RMSEA >= 0.080                NA

Standardized Root Mean Square Residual (corr metric):

  SRMR (within covariance matrix)                0.000
  SRMR (between covariance matrix)               0.000

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Observed
  Observed information based on                Hessian


Level 1 [within]:

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  mood2 ~                                             
    stress  (WPXM)    0.162    0.036    4.487    0.000
  symptoms ~                                          
    stress  (WPXY)    0.085    0.097    0.872    0.383
    mood2   (WPMY)    0.141    0.131    1.078    0.281

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          0.612    0.043   14.184    0.000
   .mood2             0.089    0.006   14.149    0.000


Level 2 [PersonID]:

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  symptoms ~                                          
    women            -0.534    0.209   -2.553    0.011
    age80             0.070    0.033    2.123    0.034
    agesex           -0.094    0.036   -2.597    0.009
  mood2 ~                                             
    women             0.008    0.054    0.152    0.879
    age80             0.013    0.008    1.628    0.104
    agesex           -0.006    0.009   -0.627    0.531
    PMstr40 (cnXM)    0.124    0.079    1.562    0.118
  symptoms ~                                          
    PMstr40 (cnXY)    1.091    0.304    3.591    0.000
    mood2   (BPMY)    1.988    0.575    3.459    0.001

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          3.336    0.539    6.190    0.000
   .mood2            -0.880    0.049  -17.866    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .symptoms          0.679    0.122    5.552    0.000
   .mood2             0.040    0.008    4.810    0.000

Defined Parameters:
                   Estimate  Std.Err  z-value  P(>|z|)
    conMtoY           1.847    0.604    3.058    0.002
    BPXtoM            0.286    0.070    4.061    0.000
    BPXtoY            1.176    0.289    4.069    0.000
    WPind             0.023    0.022    1.049    0.294
    Conind            0.228    0.164    1.393    0.163
    BPind             0.568    0.216    2.630    0.009

